<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<title>根据城市设置城市中心点</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge">
		<style>
			body,
			html,
			#container {
				overflow: hidden;
				width: 100%;
				height: 100%;
				margin: 0;
				font-family: "微软雅黑";
			}
		</style>
		<script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=CQ6PQayAcUMTO41vSdIRSsp0l2YYPyg4"></script>
	</head>

	<body>
		<div id="content">
			<input type="text" name="" id="cityv" value="上海市" />
			<input type="button" id="btn" value="搜索" />
		</div>
		<div id="container"></div>
	</body>

</html>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
	
//	$("#btn").click(function(){
//		var city = $("#cityv").val();
//		getMap(city)
//	})
	var btn = document.getElementById("btn");
	var cityv = document.getElementById("cityv");
	btn.onclick = function(){
		var city = cityv.value;
		getMap(city)
	}
	
	
	
	function getMap(city){
		var map = new BMapGL.Map('container'); // 创建Map实例
		map.centerAndZoom(city, 12); // 初始化地图,设置中心点坐标和地图级别
		map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
	}
	
	getMap("上海市")
</script>